import com.cruxconsultores.rh.Usuario
import com.cruxconsultores.rh.Role
import com.cruxconsultores.rh.UsuarioRole

class BootStrap {

    def init = { servletContext ->

        def adminRole = new Role(authority: 'ROLE_ADMIN').save(flush: true)
        def EmpleadoRole = new Role(authority: 'ROLE_EMPLEADO').save(flush: true)
        def OperadorRole = new Role(authority: 'ROLE_OPERADOR').save(flush: true)

        def adminUser = new Usuario(username: 'admin_rh', enabled: true, password: 'Password1.')
        adminUser.save(flush: true)

        UsuarioRole.create adminUser, adminRole, true

        assert Usuario.count() == 1
        assert Role.count() == 3
        assert UsuarioRole.count() == 1
    }
    def destroy = {
    }
}
